﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
namespace MyWeb.Data
{
	public class tblOrderDetailDAL : SqlDataProvider
	{

		#region[tblOrderDetail_GetbyAll]
		public DataTable tblOrderDetail_GetByAll()
		{
			using (var cmd = new SqlCommand("sp_tblOrderDetail_GetByAll", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tblOrderDetail_GetbyId]
		public DataTable tblOrderDetail_GetById(tblOrderDetailInfo Data)
		{
			using (var cmd = new SqlCommand("sp_tblOrderDetail_GetById", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@_odid", Data._odid));
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tblOrderDetail_GetbyTop]
		public DataTable tblOrderDetail_GetByTop(string Top, string Where, string Order)
		{
			using (var cmd = new SqlCommand("sp_tblOrderDetail_GetByTop", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				var da = new SqlDataAdapter(cmd);
				cmd.Parameters.Add(new SqlParameter("@Top",Top));
				cmd.Parameters.Add(new SqlParameter("@Where",Where));
				cmd.Parameters.Add(new SqlParameter("@Order",Order));
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tblOrderDetail_Getby_imgid]
		public DataTable tblOrderDetail_GetBy_imgid(string _imgid)
		{
			using (var cmd = new SqlCommand("sp_tblOrderDetail_GetBy_imgid", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@_imgid", _imgid));
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tblOrderDetail_Getby_oid]
		public DataTable tblOrderDetail_GetBy_oid(string _oid)
		{
			using (var cmd = new SqlCommand("sp_tblOrderDetail_GetBy_oid", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@_oid", _oid));
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tblOrderDetail_Insert]
		public void tblOrderDetail_Insert(tblOrderDetailInfo Data)
		{
			using (var cmd = new SqlCommand("sp_tblOrderDetail_Insert", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				
				cmd.Parameters.Add(new SqlParameter("@_price", Data._price));
				cmd.Parameters.Add(new SqlParameter("@_quantity", Data._quantity));
				cmd.Parameters.Add(new SqlParameter("@_status", Data._status));
				cmd.Parameters.Add(new SqlParameter("@_timeship", Data._timeship));
				cmd.Parameters.Add(new SqlParameter("@_address", Data._address));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
		#region[tblOrderDetail_Update]
		public void tblOrderDetail_Update(tblOrderDetailInfo Data)
		{
			using (var cmd = new SqlCommand("sp_tblOrderDetail_Update", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@_odid", Data._odid));
				cmd.Parameters.Add(new SqlParameter("@_price", Data._price));
				cmd.Parameters.Add(new SqlParameter("@_quantity", Data._quantity));
				cmd.Parameters.Add(new SqlParameter("@_status", Data._status));
				cmd.Parameters.Add(new SqlParameter("@_timeship", Data._timeship));
				cmd.Parameters.Add(new SqlParameter("@_address", Data._address));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
		#region[tblOrderDetail_Delete]
		public void tblOrderDetail_Delete(string Data)
		{
			using (var cmd = new SqlCommand("sp_tblOrderDetail_Delete", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@_odid", Data));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
	}
}